package com.example.de;


import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatCheckBox;
import androidx.appcompat.widget.AppCompatRadioButton;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.appcompat.widget.SwitchCompat;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;

import com.google.android.material.snackbar.BaseTransientBottomBar;
import com.google.android.material.snackbar.Snackbar;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        AppCompatTextView mainTextView = findViewById(R.id.mainTextView);
        AppCompatRadioButton boyRadioButton = findViewById(R.id.boyRadioButton);
        AppCompatRadioButton girlRadioButton = findViewById(R.id.girlRadioGroup);

        AppCompatCheckBox oneCheckBox = findViewById(R.id.oneCheckBox);
        AppCompatCheckBox twoCheckBox = findViewById(R.id.twoCheckBox);
        AppCompatCheckBox thrCheckBox = findViewById(R.id.thrCheckBox);

        SwitchCompat usbSwitch = findViewById(R.id.usbSwitch);

        //简写方式：鼠标放到灰色代码部分，按 alt + enter
        mainTextView.setOnClickListener(view -> {
            //在这里写点击后要执行操作,代码
            //Snackbar.make(mainTextView,"点了一下", BaseTransientBottomBar.LENGTH_SHORT).show();
            /*
            if (boyRadioButton.isChecked()) {
                Snackbar.make(mainTextView, "男被选中了", BaseTransientBottomBar.LENGTH_SHORT).show();
            } else {
                Snackbar.make(mainTextView, "女被选中了", BaseTransientBottomBar.LENGTH_SHORT).show();
            }
            //三个复选框都被选中才能检验通过
            if (oneCheckBox.isChecked() && twoCheckBox.isChecked() && thrCheckBox.isChecked()) {
                //校验通过
                Snackbar.make(mainTextView, "校验通过", BaseTransientBottomBar.LENGTH_SHORT).show();
            }else{
                //检验不通过
                Snackbar.make(mainTextView, "校验不通过", BaseTransientBottomBar.LENGTH_SHORT).show();
            }
            */
            Snackbar.make(mainTextView, usbSwitch.isChecked() + "", BaseTransientBottomBar.LENGTH_SHORT).show();
        });

    }

}
